﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ccit.Utils;
 
using System.Collections.Generic;
using Ccit.OA.MsQuestion;
using Ccit.Message.Organ;

namespace Ccit.OA.Question
{
    public class QuestionBLL
    {
        private IQuestion iQuestion = null;
        public QuestionBLL()
        {
            iQuestion = (IQuestion)Factory.CreateObject("Ccit.OA.Question.dll", "Ccit.OA.Question.Question",
                                                ImportComponentType.DotNetDll, null);
        }
         #region 获取问卷列表信息
        /// <summary>
        /// 获取问卷列表信息
        /// </summary>
        /// <param name="Query"></param>
        /// <returns></returns>
        public List<MsQuestionMes> GetQuestionMes(string Query,string stype)
        {
            List<MsQuestionMes> lstMes = iQuestion.GetQuestionMes(Query, stype);
            iQuestion = null;
            return lstMes;
        }
        /// <summary>
        /// 删除和修改操作
        /// </summary>
        /// <param name="sRecId"></param>
        /// <param name="ms"></param>
        /// <param name="type">0修改1删除</param>
        /// <returns></returns>
        public List<string> DoOperate(string sRecId, MsQuestionMes ms, string type)
        {
            List<string> lstResult = iQuestion.DoOperate(sRecId, ms, type);
            iQuestion = null;
            return lstResult;
        }
        /// <summary>
        /// 保存问卷信息
        /// </summary>
        /// <param name="ms"></param>
        /// <returns></returns>
        public List<string> DoSaveMes(MsQuestionMes ms)
        {
            List<string> lstResult = iQuestion.DoSaveMes(ms);
            iQuestion = null;
            return lstResult;
        }
         /// <summary>
        /// 复制
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns>
        public List<string> DoCopyMes(string sRecId)
        {
            List<string> lstResult = iQuestion.DoCopyMes(sRecId);
            iQuestion = null;
            return lstResult;
        }
        /// <summary>
        /// 保存问卷问题
        /// </summary>
        /// <param name="lstTions"></param>
        /// <returns></returns>
        public List<string> DoSaveQuestions(MsQuentions ms)
        {
            List<string> lstResult = iQuestion.DoSaveQuestions(ms);
            iQuestion = null;
            return lstResult;
        }
        /// <summary>
        /// 获取编辑问卷信息
        /// </summary>
        /// <param name="sRecid"></param>
        /// <returns></returns>
        public MsQuestionMes GetQuestions(string sRecid)
        {
            MsQuestionMes msMes = iQuestion.GetQuestions(sRecid);
            //iQuestion = null;
            return msMes;
        }
         /// <summary>
        /// 获取问卷问题信息
        /// </summary>
        /// <param name="sRecid"></param>
        /// <returns></returns>
        public DataSet GetQuestion(string sRecid,string stype)
        {
            DataSet dSet = iQuestion.GetQuestion(sRecid,stype);
            //iQuestion = null;
            return dSet;
        }
        /// <summary>
        /// 删除问题
        /// </summary>
        /// <param name="sRecid"></param>
        /// <returns></returns>
        public List<string> DoOperateTions(string sRecid,string type)
        {
            List<string> lstResult = iQuestion.DoOperateTions(sRecid,type);
            iQuestion = null;
            return lstResult;
        }
        /// <summary>
        /// 点击顺序上
        /// </summary>
        /// <param name="sRecId"></param>
        /// <param name="sCurrOrder"></param>
        /// <returns></returns>
        public string MoveUp(string sRecId, string sCurrOrder)
        {
            string iNum = iQuestion.MoveUp(sRecId, sCurrOrder);
            iQuestion = null;
            return iNum;
        }
        /// <summary>
        /// 点击顺序下
        /// </summary>
        /// <param name="sRecId"></param>
        /// <param name="sCurrOrder"></param>
        /// <returns></returns>
        public string MoveDown(string sRecId, string sCurrOrder)
        {
            string iNum = iQuestion.MoveDown(sRecId, sCurrOrder);
            iQuestion = null;
            return iNum;
        }
         /// <summary>
        /// 获取问卷问题选项信息
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns>
        public string GetQuestionInfo(string sRecId)
        {
            string iNum = iQuestion.GetQuestionInfo(sRecId);
            //iQuestion = null;
            return iNum;
        }
        /// <summary>
        /// 获取部门下的人员
        /// </summary>
        /// <param name="deptId"></param>
        /// <returns></returns>
        public List<MsUser> GetUserByDeptId(string deptId, string sRecId, string stype)
        {
            List<MsUser> lstUser = iQuestion.GetUserByDeptId(deptId, sRecId, stype);
            //iQuestion = null;
            return lstUser;
        }
         /// <summary>
        /// 判断部门下是否存在人员
        /// </summary>
        /// <param name="deptId"></param>
        /// <returns></returns>
        public bool CheckUserbyDeptId(string deptId)
        {
            bool bflag = iQuestion.CheckUserbyDeptId(deptId);
            //iQuestion = null;
            return bflag;
        }
         /// <summary>
        /// 根据传入的XML判断没有子部门下的部门是否有人员
        /// </summary>
        /// <param name="subDeptXML"></param>
        /// <returns></returns>
        public string checkHasUsers(string subDeptXML)
        {
            string bflag = iQuestion.checkHasUsers(subDeptXML);
            //iQuestion = null;
            return bflag;
        }

        public DataSet GetQuestionsMesInfo(string sUserId)
        {
            DataSet dSet = iQuestion.GetQuestionsMesInfo(sUserId);
            return dSet;
        }
         /// <summary>
        /// 保存记录信息和其他意见信息(qst_a4:qst_a5)
        /// </summary>
        /// <param name="ms"></param>
        /// <returns></returns>
        public List<string> DoSaveQuestionMessage(MsQuentions ms)
        {
            List<string> lstResult = iQuestion.DoSaveQuestionMessage(ms);
            return lstResult;
        }
         /// <summary>
        /// 获取问卷列表浏览信息
        /// </summary>
        /// <param name="Query"></param>
        /// <returns></returns>
        public List<MsQuestionMes> GetQuestionMesView(string Query)
        {
            List<MsQuestionMes> lstMes = iQuestion.GetQuestionMesView(Query);
            //iQuestion = null;
            return lstMes;
        }
         /// <summary>
        /// 获取问卷统计表
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns>
        public DataSet GetQuestionsCount(string sRecId, string xRecid)
        {
            DataSet dSet = iQuestion.GetQuestionsCount(sRecId,xRecid);
            return dSet;
        }
         /// <summary>
        /// 获取其他意见树信息
        /// </summary>
        /// <param name="Query"></param>
        /// <returns></returns>
        public string GetOptionsMes(string Query)
        {
            string sXml = iQuestion.GetOptionsMes(Query);
            iQuestion = null;
            return sXml;
        }
        /// <summary>
        /// 获取其他意见信息
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns> 
        public DataSet GetOptionsMessage(string Query, string type)
        {
            DataSet dSet = iQuestion.GetOptionsMessage(Query, type);
            //iQuestion = null;
            return dSet;
        }
         /// <summary>
        /// 获取问卷信息
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns>
        public MsQuestionMes GetQuestionsMessage(string sRecId)
        {
            MsQuestionMes ms = iQuestion.GetQuestionsMessage(sRecId);
            //iQuestion = null;
            return ms;
        }
         /// <summary>
        /// 获取已答人员信息
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="QId">问卷id</param>
        /// <returns></returns>
        public string GetQuestionsTime(string userId, string QId)
        {
            string iNum = iQuestion.GetQuestionsTime(userId, QId);
            return iNum;
        }
        /// <summary>
        /// 获取答案信息
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns>
        public string GetAnswerMes(string sRecId, string sUserId)
        {
            string iNum = iQuestion.GetAnswerMes(sRecId, sUserId);
            return iNum;
        }
         /// <summary>
        /// 获取选项信息
        /// </summary>
        /// <param name="sRecId"></param>
        /// <returns></returns>
        public string GetOptionsMessage(string sRecId)
        {
            string iNum = iQuestion.GetOptionsMessage(sRecId);
            return iNum;
        }
        /// <summary>
        /// 获取意见表意见信息
        /// </summary>
        /// <param name="sRecId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string GetOptionsMessages(string sRecId, string userId)
        {
            string iNUm = iQuestion.GetOptionsMessages(sRecId, userId);
            return iNUm;
        }
        #endregion  
         /// <summary>
        /// 获取部门树休息
        /// </summary>
        /// <param name="sUserId"></param>
        /// <returns></returns>
        public string GetStairAddrs(string sUserId)
        {
            string Addrs = iQuestion.GetStairAddrs(sUserId);
            return Addrs;
        }
        public string GetWorkRemind(string Qid)
        {
            string iNum = iQuestion.GetWorkRemind(Qid);
            return iNum;
        }
    }
}
